package com.moli.iov.open.web.controller;

import com.moli.iov.base.model.dto.req.SysParamSettingsReqDto;
import com.moli.iov.open.model.vo.req.BaseVo;
import com.moli.iov.open.model.vo.req.SysParamSettingsReqVo;
import com.moli.iov.open.service.SysParamSettingsService;
import com.moli.iov.rest.RestResponse;
import com.moli.iov.util.CommonUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * The type Sys param settings controller.
 *
 * @author whl
 */
@Slf4j
@RestController
@RequestMapping("/sys/sysParamSettings")
public class SysParamSettingsController extends BaseController {
    @Autowired
    private SysParamSettingsService sysParamSettingsService;

    /**
     * 系统设置参数列表
     */
    @PostMapping("/list")
    public RestResponse listSysParamSettings(
    ) {
        BaseVo baseVo = getBaseVo();
        return sysParamSettingsService.getSysParamSettings(baseVo.getCompanyId());
    }

    /**
     * 更新
     * @param vo
     * @return
     */
    @PostMapping("/update")
    public RestResponse updateSysParamSettings(
            @Validated @RequestBody SysParamSettingsReqVo vo) {
        assembleUserInfo(vo);
        SysParamSettingsReqDto dto = new SysParamSettingsReqDto();
        CommonUtils.copyProperties(vo, dto);
        return sysParamSettingsService.updateSysParamSettings(dto);
    }
}
